package com.kolaxy.social.govern.report.mapper;

import com.kolaxy.social.govern.report.domain.ReportTaskVote;
import org.apache.ibatis.annotations.*;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * <p>todo</p>
 *
 * @author zhourunjin
 * @date 2020/9/4 12:56
 */
@Mapper
public interface ReportTaskVoteMapper {

    @Insert("insert into report_task_vote(reviewer_id, vote_result, report_task_id) " +
            "values(#{reviewerId}, #{voteResult}, #{reportTaskId})")
    void insert(ReportTaskVote reportTaskVote);

    @Update("update reprot_task_vote set vote_result = #{voteResult} where reviewer_id = #{reviewerId} and reprot_task_id = #{reportTaskId}")
    void update (ReportTaskVote reportTaskVote);

    @Select("select  * from  reprot_task_vote where  reprot_task_id = #{reportTaskId}")
    @Results({
            @Result(column = "id", property = "id", id = true),
            @Result(column = "review_id", property = "reviewId"),
            @Result(column = "report_task_id", property = "reportTaskId"),
            @Result(column = "vote_result", property = "voteResult"),
    })
    List<ReportTaskVote> selectAllByReportTaskId(@Param("reportTaskId") Long reportTaskId);
}
